<?php include("includes/comunes.php");


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>&lt; PORTAL DE LA MUNICIPALIDAD DE RESISTENCIA &gt;</title>
<link href="estilos.css" rel="stylesheet" type="text/css" />


<link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'/>
<link href="../menu/css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../slide/css/basic-jquery-slider.css"/>
<script src="../slide/js/libs/jquery-1.6.2.min.js"></script>
<script src="../slide/js/basic-jquery-slider.js"></script>
</head>

<body>
<div id="contenedor" class="clearfix">
  <div id="header">
   <?php include("includes/header.php"); ?>
    
  </div> 
  <div id="contenido">      
      	<div id="col1">
          <div id="importante">Inicio > Resultado de Busqueda</div>
          <div id="recuadro_contenido_col1">
              <div class="h2">Resultados de Busqueda</div>
          
          
<div class="txt_contenido">
<?php
if( $_POST['busqueda'] )
{


   /* Get timestamp before executing the query: */
   $start_time = getmicrotime();

   /* Set $keyword and $results, and use addslashes() to
    *  minimize the risk of executing unwanted SQL commands: */
   $busqueda = addslashes( $_POST['busqueda'] );
//   $results = addslashes( $_POST['results'] );

   /* Execute the query that performs the actual search in the DB: */
   $sqlresultado=" SELECT p.page_url AS url,
                           COUNT(*) AS occurrences
                           FROM busqueda_page p, busqueda_word w, busqueda_occurrence o
                           WHERE p.page_id = o.page_id AND
                           w.word_id = o.word_id AND
                           w.word_word = \"$busqueda\"
                           GROUP BY p.page_id
                           ORDER BY occurrences DESC
                           LIMIT 50" ;
   $resres=ins_sql($sqlresultado);
   /* Get timestamp when the query is finished: */
   $end_time = getmicrotime();
/* Present the search-results: */
   print "<h3>Resultado de busqueda para '".$_POST['busqueda']."':</h2>\n";
   for( $i = 1; $row = mysql_fetch_array($resres); $i++ )
   {

      $tratar=explode('?', $row['url']) ;
    
        if(substr($tratar[1],0,6)=="pag_id"){
           
           $pag=explode('=', $tratar[1]);

           if(obtener_nombre_pagina($pag[1])<>"")
            print "$i. <a href='".utf8_encode ($row['url'])."' class='link4'>". utf8_encode (obtener_nombre_pagina($pag[1]))."</a>\n";
            else
                 print "$i. <a href='".utf8_encode ($row['url'])."' class='link4'>".utf8_encode ($row['url'])."</a>\n";

        }
        else
           print "$i. <a href='".utf8_encode ($row['url'])."' class='link4'>".utf8_encode ($row['url'])."</a>\n";
      print "(Coincidencias: ".$row['occurrences'].")<br><br>\n";
   }

   /* Present how long it took the execute the query: */
   print "Consulta ejecutada en ".(substr($end_time-$start_time,0,5))." segundos.";
}
else
{
   /* If no keyword is defined, present the search page instead: */
   echo ' <form action="resultados.php" method="post">
    <input name="busqueda" type="text" class="buscador_campo" value="Ingrese su busqueda..." maxlength="50" />
    <input name="Buscar" type="submit" class="buscador_boton" value="&gt;" />
    </form>';
}



?>
</div>
    </div>
     	</div>
        <div id="col2">
        <?php 
               include("includes/lateral_der.php");
  
          ?>

        </div>
        
  
   </div> 
<?php include("includes/footer.php"); ?>
</div>
</body>
</html>